<?php
/**
* @version $Id: news.php 10002 2008-02-08 10:56:57Z willebil $
* @package Joomla
* @subpackage news
* @copyright Copyright (C) 2005 Open Source Matters. All rights reserved.
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/

// no direct access
defined( '_VALID_MOS' ) or die( 'Restricted access' );

require_once( $mainframe->getPath( 'front_html', 'com_order' ) );

switch( $task ) {
	case 'order':
		contactpage( $pro_id );
		break;
	case 'cart':
		showCart();
		break;	
			
	default:
		contactpage();
		break;	
}

//Contact Us
function contactpage($pro_id) {
global $database, $mosConfig_live_site, $mosConfig_mailfrom;
	$hid			= intval(mosGetParam($_REQUEST, 'hid', 0));
	$fullname		= mosGetParam($_REQUEST, 'fullname', '');
	$address		= mosGetParam($_REQUEST, 'address', '');
	$phone			= mosGetParam($_REQUEST, 'phone', '');
	$email			= mosGetParam($_REQUEST, 'email', '');
	$content		= mosGetParam($_REQUEST, 'content', '');
	
	if ($hid==1){
		$subject = "THÔNG TIN LIÊN HỆ TỪ WEBSITE";
		$text.= "Họ và tên : ".$fullname."\n";
		$text.= "Địa chỉ : ".$address."\n";
		$text.= "Điện thoại : ".$phone."\n";
		$text.= "E-mail : ".$email."\n";	
		$text.= "Thông tin liên hệ : ".$content."\n";

		$success = mosMail( $email, $name, array($mosConfig_mailfrom,$email), $subject, $text );	
		if ($success){
			//$sql = "INSERT INTO jos_order(name,phone,email,address,content,groups) VALUES('".$fullname."','".$phone."','".$email."','".$address."','".$content."',".$groups.")";
			//mysql_query($sql);
			$msg = 'Bạn đã gửi thư thành công, chúng tôi sẽ liên hệ lại với bạn trong thời gian sớm nhất !';
			mosRedirect( 'index.php?option=com_order&task=order&msg='.$msg);
		}else{			
			$msg = 'Có lỗi xảy ra trong quá trình gửi thư, vui lòng thử lại !';
			mosRedirect( 'index.php?option=com_order&task=order&msg='.$msg);
		}
	}
	HTML_order::contactpage($msg);
}

//Show Cart
function showCart(){
	HTML_order::showCart();
}
?>